﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JV.MVVM.Test {
    class ViewModel: JV.MVVM.ViewModelBase {

        string _labelText;
        public string labelText {
            get { return _labelText; }
            set {
                if ( _labelText != value ) {
                    _labelText = value;
                    OnPropertyChanged( "labelText" );
                }
            }
        }

        JV.MVVM.Command _Clicked;
        public JV.MVVM.Command Clicked {
            get {
                if ( _Clicked == null ) {
                    _Clicked = new JV.MVVM.Command( p => {
                        Text = "Clicked!";
                    }, p => Text != "" );
                }
                return _Clicked; 
            }
        }

        string _Text = "not clicked";
        [Size(10)]
        public string Text {
            get { return _Text; }
            set {
                if ( _Text != value ) {
                    _Text = value;
                    OnPropertyChanged( "Text" );
                    Clicked.OnCanExecuteChanged( );
                }
            }
        }



    }
}
